<?php
/**
 * GlobalConst.php
 * @copyright (c) 2012-2020, Hangzhou DOJI Tech Co., Ltd.
 * This is NOT a freeware, use is subject to license terms.
 * @package GlobalConst.php
 * @link https://www.tingjunapp.com/
 * @author wujun@lanqb.cn
 * @: GlobalConst.php 310000 2020-11-06 16:09:25 $
 * */

namespace App\Consts;

/**
 * 全局通用常量定义
 * @author dumpling
 * 注意：
 *  1. 文件由来：为了使model整洁
 *  2. 目前存放【第三方配置，接口签名配置，token验证，每页配置，登录】
 */
class GlobalConst
{

    /* @title 公共状态常量
     * 公共状态常量--------start----------------------------------------------------------------------------------------------
     * */

    // 项目类型 文章1，笔记传2，评论3,回复传4，动态传5，专题传6，音频7 ，8收藏夹
    public const TYPE_ARTICLE = 1; //文章
    public const TYPE_NOTE = 2; //笔记
    public const TYPE_COMMENT = 3;
    public const TYPE_REPLY = 4;
    public const TYPE_DYNAMIC = 5;
    public const TYPE_TOPIC = 6;
    public const TYPE_AUDIO = 7;
    public const TYPE_FAVORITE = 8;//收藏夹


    //文件下载类型 SysFileLibrary type 类型：1文章2专题3用户4标签5金句分享
    public const FILE_UPLOAD_TYPE_ARTICLE = 1;
    public const FILE_UPLOAD_TYPE_TOPIC = 2;
    public const FILE_UPLOAD_TYPE_USER = 3;
    public const FILE_UPLOAD_TYPE_TAG = 4;
    public const FILE_UPLOAD_TYPE_GOLD_SHARE = 5; // 金句分享
    public const FILE_UPLOAD_TYPE_AD = 6;

    /*公共状态常量--------end-----------------------------------------------------------------------------------------*/



    /* @title 系统常量
     * 系统常量--------start----------------------------------------------------------------------------------------------
     * */
    public const DATABASE_TABLE_NUM = 4; //数据库分表数量
    // 当使用 yii 命令时，要传入php
    public const PHP_PATH = '/usr/local/php/bin/php';

    //每页返回数量
    public const BASE_PAGE_COUNT = 20;

    public const PAGESIZE_ONE = 1;
    public const PAGESIZE_TWO = 2;
    public const PAGESIZE_THREE = 3;
    public const PAGESIZE_FOUR = 4;
    public const PAGESIZE_FIVE = 5;
    public const PAGESIZE_NINE = 9;
    public const PAGESIZE_TEN = 10;
    public const PAGESIZE_TWELVE = 12;
    public const PAGESIZE_TWENTY = 20;
    public const PAGESIZE_TWENTY_FOUR = 24;

    /*系统常量--------end-----------------------------------------------------------------------------------------*/


    /* @title token，签名登录相关常量
     * token，签名登录相关常量--------start----------------------------------------------------------------------------------------------
     * */

    public const TOKEN_ENCRYPT_METHOD = 'AES-128-CBC';//token 算法
    public static $accessTokenIsExpired = 200; //token
    // 游客信息过期时间
    public const TOURIST_INFO_EXPIRED = 86400;
    // access_token过期时间
    public const ACCESS_TOKEN_EXPIRED = 86400;

    // refresh_token过期时间
    public const REFRESH_TOKEN_EXPIRED = 7 * 86400;


    // 登陆方式：1手机号验证码，2手机号密码，3QQ，4微信，5微博
    public const LOGIN_METHOD_TEL = 1;
    public const LOGIN_METHOD_TEL_PASSWORD = 2;
    public const LOGIN_METHOD_TENCENT = 3;
    public const LOGIN_METHOD_WECHAT = 4;
    public const LOGIN_METHOD_SINA = 5;


    // PC端access_token前8位的secret
    public const PC_TOKEN_SECRET = '3iGj!WiU';

    // pc接口签名验证secret
    public const PC_SIGN_SECRET = 'i^!$K*ttZS@eL1jaYq^xs*z4pVv1bwoz';
    public const IOS_SIGN_SECRET = 'hez1WNe1*XvbdIo!OG27o3Nkh28Bwf3W';
    public const ANDROID_SIGN_SECRET = '4Nrblrm$RVUi5B9zDx*JDpoo6gkkjJVO';

    // 登录端：1PC，2小程序，3iOS，4安卓
    public const LOGIN_PLATFORM_PC = 1;
    public const LOGIN_PLATFORM_APPLET = 2;
    public const LOGIN_PLATFORM_IOS = 3;
    public const LOGIN_PLATFORM_AN = 4;

    public static $loginPlatform = [
        self::LOGIN_PLATFORM_PC => 'loginPc',
        self::LOGIN_PLATFORM_APPLET => 'loginApplet',
        self::LOGIN_PLATFORM_IOS => 'loginIos',
        self::LOGIN_PLATFORM_AN => 'loginAn'
    ];
    public static $secret = [
        self::LOGIN_PLATFORM_PC => [
            'tokenSecret' => '3iGj!WiU',
            'tokenIv' => 'V5y&jH&P6tY#3jnE',//token 加密解密iv，必须16位
            'signSecret' => 'i^!$K*ttZS@eL1jaYq^xs*z4pVv1bwoz',
        ],
        self::LOGIN_PLATFORM_IOS => [
            'tokenSecret' => '3Oe#UKTn',
            'tokenIv' => 'ZqcQqIK!U1Iz8rnu',//token 加密解密iv，必须16位
            'signSecret' => 'hez1WNe1*XvbdIo!OG27o3Nkh28Bwf3W',
        ],
        self::LOGIN_PLATFORM_AN => [
            'tokenSecret' => 'YlS$%7to',
            'tokenIv' => 'rWvJ9%8&EYOhdpSu',//token 加密解密iv，必须16位
            'signSecret' => '4Nrblrm$RVUi5B9zDx*JDpoo6gkkjJVO',
        ],
    ];

    /*token，签名登录相关常量--------end-----------------------------------------------------------------------------------------*/




    /* @title 第三方常量
     * 第三方常量相关常量--------start----------------------------------------------------------------------------------------------
     * */

    /// 短信模板：1登录，2绑定手机号，3解绑手机号，4注册，5找回密码
    public const SMS_TEMPLATE_LOGIN = 1;
    public const SMS_TEMPLATE_BIND = 2;
    public const SMS_TEMPLATE_UNBIND = 3;
    public const SMS_TEMPLATE_SIGN = 4;
    public const SMS_TEMPLATE_PASSWORD = 5;


    //第三方登录类
    //public static $authClass = [
    //    3 => AuthTencent::class,
    //    4 => AuthWechat::class,
    //    5 => AuthWeibo::class,
    //];

    //文件上传oss 路径
    //用户头像路径
    const USER_COVER_OBJECT_PATH = 'resources/user/cover/';//GlobalConst::OBJECT_ARTICLE_BACKUPS_WORD_PATH
    // 金句分享完整图保存路
    const COMPLETE_OBJECT_PATH = 'resources/share/complete/';
    // 金桔分享小程序二维码保存路径
    const QRCODE_OBJECT_PATH = 'resources/share/';
    //协议路径
    public const AGREEMENT_OBJECT_PATH = 'resources/agreement/';
    //banner路径
    const BANNER_OBJECT_PATH = 'resources/banner/';
    const OBJECT_ARTICLE_INFO_PATH = 'resources/article/info/'; //文章静态化资源
    const OBJECT_ARTICLE_COVER_PATH = 'resources/article/cover/';//文章封面图
    const OBJECT_ARTICLE_EDITOR_PATH = 'resources/article/editor/';//文章正文中的图片
    const OBJECT_ARTICLE_BACKUPS_WORD_PATH = 'resources/article/backups/word/';//文章备份word
    const OBJECT_ARTICLE_BACKUPS_PDF_PATH = 'resources/article/backups/pdf/';//文章备份pdf

    /*第三方常量，签名登录相关常量--------end-----------------------------------------------------------------------------------------*/


    /* @title 统计相关常量
     * 统计相关常量--------start----------------------------------------------------------------------------------------------
     * */
    public const UPDATE_COUNTERS_INCREASE = 1;
    public const UPDATE_COUNTERS_DECREASE = -1;


    // 更新计数类型
    public static $countTarget = [
        1 => 'user',
        2 => 'author',
        3 => 'article',
        4 => 'topic',
        5 => 'note',
        6 => 'dynamic',
        7 => 'comment',
        8 => 'reply',
        9 => 'audio',
        10 => 'project',
    ];

    /*统计相关常量--------end-----------------------------------------------------------------------------------------*/



    /* @title 默认初始值常量
     * 默认初始值常量--------start----------------------------------------------------------------------------------------------
     * */

    // 热门标签分类ID
    public const TAG_CATEGORY_HOT_ID = 10001;//GlobalConst::TAG_CATEGORY_TOP_PARENT
    // 其他标签分类ID
    public const TAG_CATEGORY_OTHER_ID = 29;
    //标签父级分类id
    public const TAG_CATEGORY_TOP_PARENT = 0;
    public const DEFAULT_WEIGHT = 0;//默认权重
    public const FAVORITE_DEFAULT_NAME = '默认收藏夹';//

    /*默认初始值常量--------------end------------------------------------------------------------------------------*/


    /* @title 值域常量
     * 值域常量--------start----------------------------------------------------------------------------------------------
     * */

    //是否已读，1未读，2已读
    public const IS_NOT_READ = 1;
    public const IS_READ = 2;
    //0正常1删除
    public const DEL_NORMAL = 0;
    public const DEL_DELETE = 1;
    //是否使用 1未使用 2已使用
    const IS_NOT_USED = 1; //未使用
    const IS_USED = 2; //已使用
    //是否为默认 1否，2是
    public const IS_NOT_DEFAULT = 1;
    public const IS_DEFAULT = 2;
    //是否公开，1私有，2公开
    public const IS_NOT_PUBLIC = 1;
    public const IS_PUBLIC = 2;
    // 是否失效，1没有失效，2失效
    public const IS_NOT_INVALID = 1;
    public const IS_INVALID = 2;

    // 是否包含媒体（音频/视频），1不包含，2包含
    public const HAVE_NOT_MEDIA = 1;
    public const HAVE_MEDIA = 2;
    // 是否分发：1未分发，2已分发
    public const IS_NOT_ISSUE = 1;
    public const IS_ISSUE = 2;
    // 是否被推荐
    public const IS_NOT_RECOMMEND = 1;
    public const IS_RECOMMEND = 2;//GlobalConst::CHECK_STATUS_UNPASS
    //是否被屏蔽，1否2是
    public const STATUS_NORMAL = 1;// 未屏蔽/正常
    public const STATUS_SHIELD = 2; // 已屏蔽
    //状态，1禁用2启用
    public const STATUS_DISABLE = 0;
    public const STATUS_ENABLE = 1;
    //是否展示 1不展示，2展示
    const NOT_IS_VIEW = 1; //
    const IS_VIEW = 2;  //
    //创建来源，1官方2用户
    public const TYPE_OFFICIAL = 1; //官方
    public const TYPE_USER = 2; //用户

    // 审核状态，1待审核，2通过审核，3屏蔽
    const CHECK_STATUS_UNPASS = 1;
    const CHECK_STATUS_PASS = 2;
    const CHECK_STATUS_SHIELD = 3;

    // 排序规则
    public const ORDER_TYPE_DESC = 'desc';
    public const ORDER_TYPE_ASC = 'asc';

    // 是否被精选，1否2是
    public const IS_NOT_CHOICE = 1;
    public const IS_CHOICE = 2;

    /*值域常量--------------end------------------------------------------------------------------------------*/


    /* @title 最大数量/次数，限制常量
     * 最大数量/次数，限制常量--------start----------------------------------------------------------------------------------------------
     * */
    public const MAX_COUNT_FIVE = 5;

    /*最大数量/次数，限制常量--------------end------------------------------------------------------------------------------*/

    /*Model域常量--------------end------------------------------------------------------------------------------*/

    // 用户身份：1普通用户，2作者，3游客
    public const IDENTITY_USER = 1;
    public const IDENTITY_AUTHOR = 2;
    public const IDENTITY_TOURIST = 3;

    // 用户性别：1男，2女，3保密
    public const GENDER_MAN = 1;
    public const GENDER_WOMAN = 2;
    public const GENDER_SECRECY = 3;

    // 用户状态：0删除，9禁用，10正常
    public const USER_STATUS_DELETED = 0;
    public const USER_STATUS_INACTIVE = 9;
    public const USER_STATUS_ACTIVE = 10;

    // 用户昵称前缀
    public const TOURIST_DEFAULT_NAME = '游客_';
    public const TEL_REG_DEFAULT_NAME = '听君';

    // 入驻申请状态：1未申请，2已申请，3已认证，4已退回
    public const APPLY_STATUS_NOT = 1;
    public const APPLY_STATUS_APPLY = 2;
    public const APPLY_STATUS_APPROVE = 3;
    public const APPLY_STATUS_RETURN = 4;

    // 是否参与过注册引导，1没参与过（对应前端展示），2参与过（对应前端不展示）
    public const VIEW_LEAD = 1;
    public const NOT_VIEW_LEAD = 2;

    // 是否拥有链接推荐权限：1没有，2有
    public const IS_NOT_LINK_RECOMMEND = 1;
    public const IS_LINK_RECOMMEND = 2;

    // 是否为官方账号：1不是，2是
    public const IS_NOT_OFFICIAL = 1;
    public const IS_OFFICIAL = 2;

    // 登录端：1PC，2小程序，3iOS，4安卓
    public const LOGIN_PLATFORM_ANDROID = 4;

    // 前台【文章】ID构成：00 + 8位36进制毫秒级时间戳 + 14位随机字符串 + 1位属性标识符 + 8位36进制毫秒级时间戳版本号
    public const PLATFORM_ARTICLE_SIGN = 'A';
    public const PLATFORM_DRAFT_SIGN = 'D';
    public const PLATFORM_CONTRIBUTE_SIGN = 'C';

    // 文章审核状态：1待审核，2已退回，3重新审核中，4通过
    public const AUDIT_CHECK_PENDING = 1;
    public const AUDIT_UNPASS = 2;
    public const AUDIT_REVIEW_AGAIN = 3;
    public const AUDIT_PASS = 4;

    /*Model域常量--------------end------------------------------------------------------------------------------*/

}
